// Tab页的data
let tabData = {
    tabIndex: 0,
    tabbar:{}
  
}
let tabArray=
  [ 
    {
    custom: true,
    "color": "#515151",
    "selectedColor": "#d81e06",
    "backgroundColor": "#F7F7F7",
    list: [ 
        {
            "pagePath": "pages/index/index",
            "text": "购车门店",
            "iconPath": "/icon/store_gary.png",
            "selectedIconPath": "/icon/store.png"
        },
        {
            "pagePath": "pages/mine/index",
            "text": "我的",
            "iconPath": "/icon/mine_gary.png",
            "selectedIconPath": "/icon/mine.png"
        }
]
},
{
  custom: true,
  "color": "#515151",
 "selectedColor": "#d81e06",
 "backgroundColor": "#F7F7F7",
 
  list: [
    {
      "pagePath": "pages/store/detail",
      "text": "店铺",
      "iconPath": "/icon/actives_gary.png",
      "selectedIconPath": "/icon/actives.png"
  },
  {
    "pagePath": "pages/coupon/index",
    "text": "促销",
    "iconPath": "/icon/index_gary.png",
    "selectedIconPath": "/icon/index.png"
},
{
    "pagePath": "pages/clear/index",
    "text": "国庆特惠",
    "iconPath": "/icon/active_gary.png",
    "selectedIconPath": "/icon/active.png"
},
  {
      "pagePath": "pages/mine/index",
      "text": "我的",
      "iconPath": "/icon/mine_gary.png",
      "selectedIconPath": "/icon/mine.png"
  }
]
},
{
  custom: true,
  "color": "#515151",
 "selectedColor": "#d81e06",
 "backgroundColor": "#F7F7F7",
 
  list: [
    {
      "pagePath": "pages/store/detail",
      "text": "店铺",
      "iconPath": "/icon/store_gary.png",
      "selectedIconPath": "/icon/store.png"
  },
  {
    "pagePath": "pages/coupon/index",
    "text": "促销",
    "iconPath": "/icon/index_gary.png",
    "selectedIconPath": "/icon/index.png"
}, 
{
    "pagePath": "pages/clear/index",
    "text": "国庆特惠",
    "iconPath": "/icon/active_gary.png",
    "selectedIconPath": "/icon/active.png"
},
  {
      "pagePath": "pages/mine/index",
      "text": "我的",
      "iconPath": "/icon/mine_gary.png",
      "selectedIconPath": "/icon/mine.png"
  }
]
}
];


// 更新角色
const updateRole = (that, role) => {
   // tabData.tabBar.list[0].text = role + "首页";
   console.log('role='+role)
   console.log(tabArray[role]);
   if(role==0){
    tabData.tabBar=tabArray[0]
   }else if(role==1){
    tabData.tabBar=tabArray[1]
   }else{
    tabData.tabBar=tabArray[2]
   }
//   tabData.tabBar=tabArray[role]
    updateTab(that);
}

// 更新底部高亮
const updateIndex = (that, index) => {
  console.log('index='+index)
    tabData.tabIndex = index;
    updateTab(that);
}

// 更新Tab状态
const updateTab = (that) => {
  console.log(that)
    if (typeof that.getTabBar === 'function' && that.getTabBar()) {
        that.getTabBar().setData(tabData);
    }
}

// 将可调用的方法抛出让外面调用
module.exports = {
    updateRole, updateTab, updateIndex
}